<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>重庆上善云图技术有限公司</title>
		<link rel="icon" href="<%=request.getContextPath()%>/static/common/img/favicon.png">
		<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/common/easyui/themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/common/easyui/themes/icon.css">
		<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/common/easyui/themes/color.css">
		<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/common/easyui/themes/xyy.css">
		<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/system/css/clazz.css">
		<script src="<%=request.getContextPath()%>/static/common/easyui/jquery.min.js"></script>
		<script src="<%=request.getContextPath()%>/static/common/easyui/jquery.easyui.min.js"></script>
		<script src="<%=request.getContextPath()%>/static/common/easyui/easyloader.js"></script>
		<script src="<%=request.getContextPath()%>/static/common/easyui/locale/easyui-lang-zh_CN.js"></script>	
	</head>

	<body id="body" class="easyui-layout" style="margin:0 1px;background-color:#f5f5f5 !important;font-family:Microsoft YaHei;">

		<!--刷新时候的遮罩-->
		<div id="loading-mask" style="position:absolute;top:0px; left:0px; width:100%; height:100%; background:white; z-index:20000">
			<div id="pageloading" style="position:absolute; top:50%; left:50%; margin:-60px 0px 0px -120px; text-align:center;  border:2px solid #19AA8D;border-radius:8px; width:200px; height:40px;  font-size:14px;padding:10px; font-weight:bold; background:#fff; color:#15428B;">
				<img src="<%=request.getContextPath()%>/static/common/img/loading.gif" align="absmiddle" /> <b style="color: #19AA8D">正在加载中,请稍候...</b></div>
		</div>

		<div data-options="region:'north',split:true" style="height:80px;" id="xyy_header">
			<div class="easyui-layout" data-options="fit:true">
				<div style="float:left;width:40%;padding:0px 0 0 5px;">
					<img src="<%=request.getContextPath()%>/static/common/img/logo.png">
				</div>
				<div style="float:right;width:56%;">
					<div class="xyy_tool">
						<ul style="float:right;position: relative;right:-10px;margin:0;">
							<li><a href="#"><i class="xyy-xinxi" style="position: absolute;display:block;width: 16px;height: 16px;top: 50%;margin: -8px 12px;"></i>信息中心</a></li>
							<li><a href="#" onclick="personInfo()"><i class="xyy-ziliao" style="position: absolute;display:block;width: 16px;height: 16px;top: 50%;margin: -8px 12px;"></i>资料设置</a></li>
							<li><a href="#" id="editpass"><i class="xyy-mima" style="position: absolute;display:block;width: 16px;height: 16px;top: 50%;margin: -8px 12px;"></i>修改密码</a></li>
							<li><a href="#" id="loginOut"><i class="xyy-tuichu" style="position: absolute;display:block;width: 16px;height: 16px;top: 50%;margin: -8px 12px;"></i>退出登录</a></li>
						</ul>
					</div>
				</div>
			</div>
		</div>
		
		
		<div data-options="region:'south',split:true" style="height:40px;text-align:center;line-height:30px;background:#19aa8d;color:#f5f5f5;"></div>
		<div data-options="region:'west',title:'平台管理主菜单',split:true" style="width:200px;">
			<div id="menu" class="easyui-accordion" fit="true" border="false">
				<c:if test="${systemEntiy.roleId eq 1}">
					<div title="系统模块 " data-options="iconCls:'icon-shezhi',selected:true" style="overflow:auto;padding:10px;">
						<ul id="nav"></ul>
					</div>
				</c:if>
				<c:if test="${systemEntiy.roleId  eq 3}">
					<div title="学员模块"  data-options="iconCls:'icon-guanli'" style="padding:10px;">
						<ul id="talentNav"></ul>
					</div>
				</c:if>
				<c:if test="${systemEntiy.roleId  eq 1 || systemEntiy.roleId  eq 2}">
					<div title="题库模块" data-options="iconCls:'icon-shezhi'" style="padding:10px;">
						<ul id="questionBankNav"></ul>
					</div>
				</c:if>
				<c:if test="${systemEntiy.roleId  eq 1 || systemEntiy.roleId  eq 2}">
					<div title="考试模块" data-options="iconCls:'icon-guanli'" style="overflow:auto;padding:10px;">
						<ul id="examNav"></ul>
					</div>
				</c:if>
				<div title="辅助模块" data-options="iconCls:'icon-shezhi'" style="overflow:auto;padding:10px;">
					<ul id="otherNav"></ul>
				</div>
			</div>

		</div>
		<div data-options="region:'center'" style="background:#fff;border:0;">
			<div id="tabs" class="easyui-tabs" data-options="tools:'#tab-tools',fit:true">
				<div title="我的主页" iconCls="icon-home" style="padding:15px;">
					<div class="easyui-layout" data-options="fit:true">
						<div data-options="region:'north',border:false" style="height:130px;border-bottom:1px #a7b1c2 dashed;padding:5px;">
							<div class="easyui-layout" data-options="fit:true">
								<div data-options="region:'west',border:false" style="width:350px;height:150px;border-right:1px #a7b1c2 dashed;padding:5px;color:#2f4050;">
									<h1 style="margin:0 0 10px 0;">欢迎使用上善云图考试系统！</h1>
									<ul style="list-style-type:none;padding:0;">
										<li style="margin-bottom:10px;">
											<a href="#" style="text-decoration:none;font-size:16px;color:#2f4050;"><i class="xyy-hello" style="display:block;width: 16px;height:16px;float:left;margin:2px 3px;"></i>您好,<span class="tag" style="color:red;">${systemEntiy.name }</span>!</a>
										</li>
										<li style="margin-bottom:10px;"><a href="#" style="text-decoration:none;font-size:16px;color:#2f4050;"><i class="xyy-time" style="display:block;width: 16px;height:16px;float:left;margin:2px 3px;"></i>现在是：<span id="timer" style="color:#19aa8d;font:16px tahoma;height:17px;"><script>setInterval("timeStr=new Date().toLocaleString();timer.innerText=timeStr;",1000)</script></span></a>
										</li>
									</ul>
								</div>
								<div data-options="region:'center',border:false" style="padding-left:30px;">
									<div class="jiankong" data-options="region:'center',border:false">
										<div class="juxing"><a href="#">选择题 <span>888</span> 个</a></div>
									</div>
									<div class="jiankong" data-options="region:'center',border:false">
										<div class="juxing"><a href="#">填空题 <span>888</span> 个</a></div>
									</div>
									<div class="jiankong" data-options="region:'center',border:false">
										<div class="juxing"><a href="#">简答题 <span>888</span> 个</a></div>
									</div>
									<div class="jiankong" data-options="region:'center',border:false">
										<div class="juxing"><a href="#">计算题 <span>888</span> 个</a></div>
									</div>
								</div>
							</div>
						</div>
						<div data-options="region:'center',border:false">
							<div data-options="region:'center',border:false" style="margin-top:20px;">
								<table id="dg" title="最新订单" iconCls="icon-dingdan" class="easyui-datagrid" style="width:100%;height:400px;" data-options="idField:'id',rownumbers:false,fitColumns:true,pagination:true,singleSelect:true,collapsible:true,toolbar:'#toolbar',url:'datagrid_data.json',method:'get',checkOnSelect:'true',selectOnCheck:'true'">
									<!---获取数据--->
									<thead>
										<tr>
											<th field="ck" checkbox="true"></th>
											<th data-options="field:'id',width:80">编 号</th>
											<th data-options="field:'name',width:100">名 字</th>
											<th data-options="field:'tel',width:100">电 话</th>
											<th data-options="field:'add',width:100">地 址</th>
											<th data-options="field:'beizhu',width:100">备 注</th>
											<th data-options="field:'timet',width:100">购买日期</th>
											<th data-options="field:'timef',width:100">浏览日期</th>
										</tr>
									</thead>
									<tbody>
										<tr>
											<td></td>
											<td>001</td>
											<td>顿饭第三季</td>
											<td>15166925589</td>
											<td>乌鲁木齐啦啦啦啦啦</td>
											<td>FI-SW-01</td>
											<td>2014-5-6</td>
											<td>2015-5-6</td>
										</tr>
										<!--<tr>
											<td></td>
											<td>002</td>
											<td>费点事</td>
											<td>15166925589</td>
											<td>乌鲁木齐啦啦啦啦啦</td>
											<td>K9-DL-01</td>
											<td>2014-5-6</td>
											<td>2015-5-6</td>
										</tr>-->
										<tr>
											<td></td>
											<td>003</td>
											<td>二位好</td>
											<td>15166925589</td>
											<td>乌鲁木齐啦啦啦啦啦</td>
											<td>RP-SN-01</td>
											<td>2014-5-6</td>
											<td>2015-5-6</td>
										</tr>
										<tr>
											<td></td>
											<td>004</td>
											<td>通过人体</td>
											<td>15166925589</td>
											<td>乌鲁木齐啦啦啦啦啦</td>
											<td>RP-SN-01</td>
											<td>2014-5-6</td>
											<td>2015-5-6</td>
										</tr>
										<tr>
											<td></td>
											<td>005</td>
											<td>太热</td>
											<td>15166925589</td>
											<td>乌鲁木齐啦啦啦啦啦</td>
											<td>RP-LI-02</td>
											<td>2014-5-6</td>
											<td>2015-5-6</td>
										</tr>
									</tbody>
								</table>
								<div id="toolbar">
									<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newUser()">新 增</a>
									<a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editUser()">编 辑</a>
									<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="removeUser()">移 除</a>
									<a href="#" class="easyui-linkbutton" plain="true">
										<span>丨选择模式: </span>
										<select onchange="$('#dg').datagrid({singleSelect:(this.value==1)})">
										<option value="1">单选</option>
										<option value="0">全选</option>
									</select>
									</a>
									<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="addTab('新增用户','add.html')">新增teg</a>
									<a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="addTab('编辑用户','edit.html')">编辑teg</a>
								</div>
								<div id="dlg" class="easyui-dialog" style="width:400px;height:280px;padding:10px 20px" closed="true" buttons="#dlg-buttons">
									<div class="ftitle">用户 信息</div>
									<form id="fm" method="post" novalidate>
										<div class="fitem">
											<label>编 号:</label>
											<input name="firstname" class="easyui-validatebox" required="true">
										</div>
										<div class="fitem">
											<label>名 字:</label>
											<input name="lastname" class="easyui-validatebox" required="true">
										</div>
										<div class="fitem">
											<label>电 话:</label>
											<input name="phone">
										</div>
										<div class="fitem">
											<label>地 址:</label>
											<input name="add" class="easyui-validatebox" validType="email">
										</div>
									</form>
								</div>
								<div id="dlg-buttons">
									<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveUser()">保存</a>
									<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">关闭</a>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<!--修改密码窗口-->

		<div id="w" class="easyui-window" title="修改密码" closed="true" collapsible="false" minimizable="false" maximizable="false" icon="icon-save" style="width: 300px; height:195px; padding: 5px;
        background: #fafafa;">
			<div class="easyui-layout" fit="true">
				<div region="center" border="false" style="padding: 10px; background: #fff; border: 1px solid #ccc;">
					<table cellpadding=3>
						<tr>
							<td>原密码:</td>
							<td><input id="txtOldPass" type="Password" class="txt01" /></td>
						</tr>
						<tr>
							<td>新密码:</td>
							<td><input id="txtNewPass" type="Password" class="txt01" /></td>
						</tr>
						<tr>
							<td>确认密码:</td>
							<td><input id="txtRePass" type="Password" class="txt01" /></td>
						</tr>
					</table>
				</div>
				<div region="south" border="false" style="text-align: center; height: 30px; line-height: 30px;"> <a id="btnEp" class="easyui-linkbutton" icon="icon-ok" href="javascript:void(0)"> 确定</a> <a id="btnCancel" class="easyui-linkbutton" icon="icon-cancel" href="javascript:void(0)">取消</a> </div>
			</div>
		</div>

		<!-- 个人信息查看 -->
		<div id="personInfo" class="easyui-dialog"  style="width:350px" data-options="
		title:'个人信息查看',
		closed:true,
		buttons: '#personInfoBtn'
		">
			<form id="personForm" method="post" style="text-align: center" action="<%=request.getContextPath()%>/SystemServlet?command=updateInfo">
				<p>
					<strong>帐　　号：</strong>
					<input type="text" name="code" id="code" class="easyui-validatebox" value="${systemEntiy.code }" readOnly="true">
				</p>
				<p>
					<strong>姓　　名：</strong>
					<input type="text" name="name" class="easyui-validatebox" value="${systemEntiy.name }" readOnly="true">
				</p>
				<p>
					<strong>电　　话：</strong>
					<input type="text" name="phone" id="personPhone" class="easyui-validatebox" value="${systemEntiy.phone }"readOnly="true">
				</p>
				<p>
					<strong>邮　　箱：</strong>
					<input type="text" name="email" id="personEmail" class="easyui-validatebox" value="${systemEntiy.email }" readOnly="true">
				</p>
				<p>
					<strong>创建时间：</strong>
					<input type="text" name="createTime" id="createTime" class="easyui-validatebox" value="${systemEntiy.createTime }" readOnly="true">
				</p>
				<p>
					<strong>角　　色：</strong>
					<input type="text" name="role" id="role" 
						<c:if test="${systemEntiy.roleId==1 }"> value='超级管理员'
						</c:if>
						<c:if test="${systemEntiy.roleId==2 }"> value='教师'
						</c:if>
						<c:if test="${systemEntiy.roleId==3 }"> value='学生'
						</c:if>
					readOnly="true">
				</p>
				<c:if test="${systemEntiy.classId !=0 }">
					<p>
						<strong>班　　级：</strong>
						<input type="clazz" name="clazz" id="code" class="easyui-validatebox" value="${systemEntiy.classId }" readOnly="true">
					</p>
				</c:if>
				
			</form>
		</div>
		<div id="personInfoBtn" style="text-align: center">
			<a href="#"  id="update" class="easyui-linkbutton" data-options="
			iconCls: 'icon-edit',
			plain: false">
				修改
			</a>
			<a href="#" id="personInfoClose" class="easyui-linkbutton" data-options="
			iconCls: 'icon-cancel',
			plain: false">
				关闭
			</a>
		</div>
		
		
		<!-- 个人信息修改 -->
		<div id="personInfoUpdate" class="easyui-dialog"  style="width:350px" data-options="
		title:'个人信息修改',
		closed:true,
		buttons: '#personInfoUpdateBtn'
		">
			<form id="personInfoUpdateForm" method="post" style="text-align: center" action="">
				<p>
					<strong>电　　话：</strong>
					<input type="text" name="phone" id="phone" class="easyui-validatebox" value="${systemEntiy.phone }" data-options="required:true,message:'phone'">
				</p>
				<p>
					<strong>邮　　箱：</strong>
					<input type="text" name="email" id="email" class="easyui-validatebox" value="${systemEntiy.email }" data-options="required:true,validType:'email'">
				</p>
			</form>
		</div>
		<div id="personInfoUpdateBtn" style="text-align: center">
			<a href="#"  id="updateInfo" class="easyui-linkbutton" data-options="
			iconCls: 'icon-edit',
			plain: false">
				确认修改
			</a>
			<a href="#" id="personInfoUpdateClose" class="easyui-linkbutton" data-options="
			iconCls: 'icon-cancel',
			plain: false">
				关闭
			</a>
		</div>
		
		



		<!--右键事件-->
		<div id="tabMenu" class="easyui-menu">
		    <div data-options="
		    name:'refresh'">
		    	刷新
		    </div>
		    <div data-options="
		    name:'closeCurrent'">
		    	关闭当前
		    </div>
		    <div data-options="
		    	name:'closeOther'">
		    	关闭其它
		    </div>
		    <div data-options="
		    	name:'closeRight'">
		    	当前页右侧全部关闭
		    </div>
		    <div data-options="
		    	name:'closeLeft'">
		    	当前页左侧全部关闭
		    </div>
		    <div data-options="
		    name:'closeAll'">
		    	关闭全部
		    </div>
		</div>

		
		
		<script>	
			var main = {
				init: function() {
					main.nav = $('#nav');
					main.talentNav = $('#talentNav');
					main.tabs = $('#tabs');
					main.tabMenu = $('#tabMenu');
					main.questionBankNav = $('#questionBankNav');
					main.examNav = $('#examNav');
					main.otherNav = $('#otherNav');
					
					// 请求tree数据
					main.nav.tree({
						url: '<%=request.getContextPath()%>/MainServlet?command=listMenu&id=1',
						lines: true,
						onLoadSuccess: function(node, data) {
							main.nav.tree('expandAll')
						},
						onClick: function(node) {
							if (node.url) {
 								if (main.tabs.tabs('exists', node.text)) {
									main.tabs.tabs('select', node.text)
								} else { 
									main.tabs.tabs('add', {
										title: node.text,
										iconCls: node.iconCls,
										closable: true,
										href: node.url
									});
						 		} 
							}
						}
					});
					main.talentNav.tree({
						url: '<%=request.getContextPath()%>/MainServlet?command=listMenu&id=2',
						lines: true,
						onLoadSuccess: function(node, data) {
							main.nav.tree('expandAll')
						},
						onClick: function(node) {
							if (node.url) {
 								if (main.tabs.tabs('exists', node.text)) {
									main.tabs.tabs('select', node.text)
								} else { 
									main.tabs.tabs('add', {
										title: node.text,
										iconCls: node.iconCls,
										closable: true,
										href: node.url
									});
						 		} 
							}
						}
					});
					
					main.questionBankNav.tree({
						url: '<%=request.getContextPath()%>/MainServlet?command=listMenu&id=3',
						lines: true,
						onLoadSuccess: function(node, data) {
							main.nav.tree('expandAll')
						},
						onClick: function(node) {
							if (node.url) {
 								if (main.tabs.tabs('exists', node.text)) {
									main.tabs.tabs('select', node.text)
								} else { 
									main.tabs.tabs('add', {
										title: node.text,
										iconCls: node.iconCls,
										closable: true,
										href: node.url
									});
						 		} 
							}
						}
					});
					
					main.examNav.tree({
						url: '<%=request.getContextPath()%>/MainServlet?command=listMenu&id=4',
						lines: true,
						onLoadSuccess: function(node, data) {
							main.nav.tree('expandAll')
						},
						onClick: function(node) {
							if (node.url) {
 								if (main.tabs.tabs('exists', node.text)) {
									main.tabs.tabs('select', node.text)
								} else { 
									main.tabs.tabs('add', {
										title: node.text,
										iconCls: node.iconCls,
										closable: true,
										href: node.url
									});
						 		} 
							}
						}
					});
					
					main.otherNav.tree({
						url: '<%=request.getContextPath()%>/MainServlet?command=listMenu&id=5',
						lines: true,
						onLoadSuccess: function(node, data) {
							main.nav.tree('expandAll')
						},
						onClick: function(node) {
							if (node.url) {
 								if (main.tabs.tabs('exists', node.text)) {
									main.tabs.tabs('select', node.text)
								} else { 
									main.tabs.tabs('add', {
										title: node.text,
										iconCls: node.iconCls,
										closable: true,
										href: node.url
									});
						 		} 
							}
						}
					});
					
					
					
			        // 初始化tab，并创建右键菜单
					main.tabs.tabs({
						border: false,
						fit: true,
			            onContextMenu: function (e, title, index) {
			                e.preventDefault();
			                if (index > 0) {
			                	main.tabMenu.menu('show', {
			                        left: e.pageX,
			                        top: e.pageY
			                    }).data("tabTitle", title);
			                }
			            }
			        });
			        
			        // 右键菜单click
			        main.tabMenu.menu({
			            onClick: function (item) {
				            var allTabs = main.tabs.tabs('tabs');
				            var allTabtitle = [];
				            $.each(allTabs, function (i, v) {
				                var opt = $(v).panel('options');
				                if (opt.closable) {
				                    allTabtitle.push(opt.title);
				                }
				            });
				            var curTabTitle = $(this).data("tabTitle");
				            var curTabIndex = main.tabs.tabs("getTabIndex", main.tabs.tabs("getTab", curTabTitle));
				            switch (item.name) {
			                	case 'refresh':
			                    	var panel = main.tabs.tabs("getTab", curTabTitle).panel("refresh");
			                    	break;
			                    	case 'closeCurrent':
				                    main.tabs.tabs("close", curTabIndex);
				                    break;
				                case 'closeOther':
				                    $.each(allTabtitle, function(i, v) {
				                        if (curTabTitle != allTabtitle[i]) {
				                            main.tabs.tabs('close', allTabtitle[i]);
				                        }
				                    });
				                    main.tabs.tabs('select', curTabTitle);
				                    break;
				                    
				                case 'closeRight':
				                	$.each(allTabtitle, function(i, v) {
				                		if ( i >= curTabIndex) {
				                            main.tabs.tabs('close', allTabtitle[i]);
				                        } 
				                    }); 
				                    main.tabs.tabs('select', curTabTitle); 
				                    break;
				                    
				              	case 'closeLeft':
				              		$.each(allTabtitle, function(i, v) {
				              			 if ( i < curTabIndex-1  ) {
				                            main.tabs.tabs('close', allTabtitle[i]);
				                        }  
				                    }); 
				                    main.tabs.tabs('select', curTabTitle); 
				                    break;
				                
				                case 'closeAll':
				                    $.each(allTabtitle, function(i, v) {
				                        main.tabs.tabs('close', allTabtitle[i]);
				                    });
				                    break;
				            }
			            }
			        });
				}
			};
			
			$(function(){
				main.init();
			});
		</script>
		
		
		<!--修改密码-->
		<script type="text/javascript">
		
			//关闭密码修改窗口
			var $oldpass = $('#txtOldPass');
			var $newpass = $('#txtNewPass');
			var $rePass = $('#txtRePass');
			function closePwd() {
				$oldpass.val('');
				$newpass.val('');
				$rePass.val('');
				$('#w').window('close');
			}

			//修改密码
			function serverLogin() {
				
				if ($oldpass.val() == '') {
					msgShow('系统提示', '请输入原密码！', 'warning');
					return false;
				}
				if ($newpass.val() == $oldpass.val()) {
					msgShow('系统提示', '新密码不能与原密码一致！', 'warning');
					return false;
				}
				if ($newpass.val() == '') {
					msgShow('系统提示', '请输入新密码！', 'warning');
					return false;
				}
				if ($rePass.val() == '') {
					msgShow('系统提示', '确认密码不能为空！', 'warning');
					return false;
				}
				if ($newpass.val() != $rePass.val()) {
					msgShow('系统提示', '两次密码不一致！请重新输入', 'warning');
					return false;
				}else {
					$.get('<%=request.getContextPath()%>/SystemServlet?command=updatePassword&code='+"${systemEntiy.code }"+'&password=' + $newpass.val() + '&time=' + new Date().getTime(), function(text){
					     if (text == '1') {
					    	msgShow('系统提示', '恭喜，密码修改成功！<br>您的新密码为：' + $newpass.val());
							closePwd();
					     }
		    		  }); 
				}

			}
			
			//原密码错误就清空原密码
			function checkPassword(){
				$('#txtOldPass').val('');
			}
			//电话号码存在就清空
			function checkPhone(){
				$('#phone').val('');
			}
			//邮箱存在就清空
			function checkEmail(){
				$('#email').val('');
			}
			//同步电话更改信息
			function personPhone(){
				$('#personPhone').val($('#phone').val());
			}
			//同步邮箱更改信息
			function personEmail(){
				$('#personEmail').val($('#email').val());
			}
			$(function() {
				
				$('#editpass').click(function() {
					$('#w').window('open');
				});
				
				$('#txtOldPass').blur(function(){
					$.get('<%=request.getContextPath()%>/SystemServlet?command=checkPassword&code='+"${systemEntiy.code }"+'&password=' + this.value + '&time=' + new Date().getTime(), function(text){
					     if (text == '1') {
					    	checkPassword();
					    	msgShow('系统提示', '原密码错误！', 'warning');
					     }
		    		}); 
				});
				
				//关闭信息查看页面
				$('#personInfoClose').click(function(){
					$('#personInfo').window('close');
				});
				
				//关闭信息查看页面
				$('#personInfoUpdateClose').click(function(){
					$('#personInfoUpdate').window('close');
				});
				
				
				$('#update').click(function(){
					$("#personInfoUpdate").window('open');
					/* $('#personInfo').window('close'); */
				});
				
				//AJAX验证电话号码，邮箱是否重复
				
				$('#phone').blur(function(){
					$.get('<%=request.getContextPath()%>/SystemServlet?command=checkPhone&code='+"${systemEntiy.code }"+'&phone=' + this.value + '&time=' + new Date().getTime(), function(text){
					     if (text == '1') {
					    	checkPhone()
					    	msgShow('系统提示', '此电话号码已存在！', 'warning');
					     }
		    		}); 
				});
				$('#email').blur(function(){
					$.get('<%=request.getContextPath()%>/SystemServlet?command=checkEmail&code='+"${systemEntiy.code }"+'&email=' + this.value + '&time=' + new Date().getTime(), function(text){
					     if (text == '1') {
					    	 checkEmail();
					    	msgShow('系统提示', '此邮箱已存在！', 'warning');
					     }
		    		}); 
				});
				
				
				$('#updateInfo').click(function(){
					var $phone=$('#phone');
					var $email = $('#email');
					var phoneReg = /^0?1[3|4|5|8][0-9]\d{8}$/;
					var emailReg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
					if ( ! phoneReg.test($phone.val())) {
						msgShow('系统提示', '请输入正确的电话号码！', 'warning');
						return false;
					}if ( ! emailReg.test($email.val())) {
						msgShow('系统提示', '请输入正确的邮箱！', 'warning');
						return false;
					}
					$.get('<%=request.getContextPath()%>/SystemServlet?command=updateInfo&code='+"${systemEntiy.code}" +'&phone='+$phone.val()+'&email='+$email.val()+ '&time=' + new Date().getTime(), function(text){
					     if (text == '1') {
					    	/*  $('#btnEp').linkbutton('disable'); */
					    	 msgShow('系统提示', '修改成功！');
					    	 $("#personInfoUpdate").window('close');
					    	 personPhone();
					    	 personEmail();
					     }
		    		}); 
				})
				
				$('#btnEp').click(function() {
					serverLogin();
				})

				$('#btnCancel').click(function() {
					closePwd();
				})
					//
				$('#loginOut').click(function() {
					$.messager.confirm('系统提示', '您确定要退出本次登录吗?', function(r) {

						if (r) {
							location.href = "<%=request.getContextPath()%>/SystemServlet?command=logout"
						}
					});
				})

			});
		</script>

		<!-- 个人信息修改 -->
		<script type="text/javascript">
			var url;
	
			function personInfo(){
				$('#personInfo').window('open');
			}
			
			function newUser() {
				$('#dlg').dialog('open').dialog('setTitle', '新增用户');
				$('#fm').form('clear');
				url = 'save_user.php';
			}

			function editUser() {
				var row = $('#dg').datagrid('getSelected');
				if (row) {
					$('#dlg').dialog('open').dialog('setTitle', '编辑用户');
					$('#fm').form('load', row);
					url = 'update_user.php?id=' + row.id;
				}
			}

			function saveUser() {
				$('#fm').form('submit', {
					url: url,
					onSubmit: function() {
						return $(this).form('validate');
					},
					success: function(result) {
						var result = eval('(' + result + ')');
						if (result.success) {
							$('#dlg').dialog('close'); // close the dialog
							$('#dg').datagrid('reload'); // reload the user data
						} else {
							$.messager.show({
								title: 'Error',
								msg: result.msg
							});
						}
					}
				});
			}

			function removeUser() {
				var row = $('#dg').datagrid('getSelected');
				if (row) {
					$.messager.confirm('Confirm', '是否确定删除?', function(r) {
						if (r) {
							$.post('remove_user.php', {
								id: row.id
							}, function(result) {
								if (result.success) {
									$('#dg').datagrid('reload'); // reload the user data
								} else {
									$.messager.show({ // show error message
										title: 'Error',
										msg: result.msg
									});
								}
							}, 'json');
						}
					});
				}
			}
		</script>

		<script type="text/javascript">
			function addTab(title, url) {
				if ($('#tb').tabs('exists', title)) {
					$('#tb').tabs('select', title);
				} else {
					var content = '<iframe scrolling="auto" frameborder="0"  src="' + url + '" style="width:100%;height:100%;"></iframe>';
					$('#tb').tabs('add', {
						title: title,
						content: content,
						closable: true
					});
				}
			}
			//关闭所有的tab  
			function closeAll() {
				var tiles = new Array();
				var tabs = $('#tb').tabs('tabs');
				var len = tabs.length;
				if (len > 0) {
					for (var j = 0; j < len; j++) {
						var a = tabs[j].panel('options').title;
						tiles.push(a);
					}
					for (var i = 1; i < tiles.length; i++) {
						$('#tb').tabs('close', tiles[i]);
					}
				}
			}
			//关闭当前的tab 
			function removePanel() {
				var tab = $('#tb').tabs('getSelected');
				if (tab) {
					var index = $('#tb').tabs('getTabIndex', tab);
					$('#tb').tabs('close', index);
				}
			}
			//表格分页	
			// get the pager of datagrid
			var pager = $('#dg').datagrid('getPager');
			pager.pagination({
				showPageList: false,
				buttons: [{
					iconCls: 'icon-search',
					handler: function() {
						alert('search');
					}
				}, {
					iconCls: 'icon-add',
					handler: function() {
						alert('add');
					}
				}, {
					iconCls: 'icon-edit',
					handler: function() {
						alert('edit');
					}
				}],
				onBeforeRefresh: function() {
					alert('before refresh');
					return true;
				}
			});
		</script> 
	</body>

</html>